import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _forEach from "lodash/forEach";
var _excluded = ["modalProps"],
    _excluded2 = ["type", "value", "modalProps"],
    _excluded3 = ["modalProps"],
    _excluded4 = ["userInfo"],
    _excluded5 = ["userInfo"];
import { queryIdpValue, queryMapIdpValue, getPublicKey as _getPublicKey } from 'cpaas-front/lib/services/api';
import notification from 'utils/notification';
import { getResponse, getSession, setSession } from 'utils/utils';
import { userInfoQuerySelf, userInfoUpdateRealName, userInfoQueryRoleDataSource, userInfoUpdateDefaultRole, userInfoUpdateDefaultCompany, userInfoUpdatePassword, userInfoValidatePre, userInfoPostOldPhoneCaptcha, userInfoValidateUnCheckedPhone, userInfoPostOldEmailCaptcha, userInfoValidateUnCheckedEmail, userInfoPostNewEmailCaptcha, userInfoPostNewPhoneCaptcha, userInfoValidateNewEmail, userInfoValidatePrePassword, userInfoValidateNewPhone, // userInfoCompanyQuery,
updateDefaultLanguage, updateDefaultMenu, updateDefaultDate, updateDefaultTimeZone, fetchEnabledFile as _fetchEnabledFile, uploadAvatar as _uploadAvatar, saveAvatar as _saveAvatar, fetchOpenAccountList as _fetchOpenAccountList, unBindOpenAccount as _unBindOpenAccount, beforeBind as _beforeBind } from "../services/userInfoService";
import { getPasswordRule as _getPasswordRule } from "../services/commonService";
export default {
  namespace: 'userInfo',
  state: {
    // 存放用户的信息
    userInfo: {},
    // 上传头像相关
    imgFormData: {},
    // 图片表单数据
    uploadImgName: '',
    // 图片名称
    uploadImgPreviewUrl: '',
    // 图片上传预览
    imgUploadStatus: 'waiting',
    // 图片上传状态
    // 公司的属性
    companyProps: {},
    // 角色的属性
    roleProps: {},
    // 模态框 邮箱 手机 密码 的属性
    modalProps: {},
    languageMap: {},
    // 系统支持的语言类型
    menuMap: {},
    // 系统支持的菜单布局
    roleMergeMap: {},
    // 系统角色合并
    dateMap: {},
    // 系统支持的日期格式
    timeMap: {},
    // 系统支持的时间格式
    openAccountList: [],
    // 第三方绑定列表
    limitData: {},
    // 头像上传文件的限制类型和大小
    passwordTipMsg: {},
    // 密码输入提示
    publicKey: '' // 密码公钥

  },
  effects: {
    // 加载用户信息并重置所有信息到初始状态
    init: /*#__PURE__*/_regeneratorRuntime.mark(function init(_ref, _ref2) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function init$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              payload = _ref.payload;
              call = _ref2.call, put = _ref2.put;
              _context.next = 4;
              return call(userInfoQuerySelf, payload);

            case 4:
              res = _context.sent;
              res = getResponse(res);

              if (!res) {
                _context.next = 9;
                break;
              }

              _context.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: res
                }
              });

            case 9:
              return _context.abrupt("return", res);

            case 10:
            case "end":
              return _context.stop();
          }
        }
      }, init);
    }),
    // 初始化当前用户角色
    initRoleDataSource: /*#__PURE__*/_regeneratorRuntime.mark(function initRoleDataSource(_, _ref3) {
      var call, put, res, roleDataSource, roleMap;
      return _regeneratorRuntime.wrap(function initRoleDataSource$(_context2) {
        while (1) {
          switch (_context2.prev = _context2.next) {
            case 0:
              call = _ref3.call, put = _ref3.put;
              _context2.next = 3;
              return call(userInfoQueryRoleDataSource);

            case 3:
              res = _context2.sent;
              roleDataSource = getResponse(res);

              if (!roleDataSource) {
                _context2.next = 10;
                break;
              }

              roleMap = {};

              _forEach(res, function (role) {
                roleMap[role.id] = role;
              });

              _context2.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  roleDataSource: roleDataSource,
                  roleMap: roleMap
                }
              });

            case 10:
            case "end":
              return _context2.stop();
          }
        }
      }, initRoleDataSource);
    }),
    getPublicKey: /*#__PURE__*/_regeneratorRuntime.mark(function getPublicKey(_, _ref4) {
      var call, put, res;
      return _regeneratorRuntime.wrap(function getPublicKey$(_context3) {
        while (1) {
          switch (_context3.prev = _context3.next) {
            case 0:
              call = _ref4.call, put = _ref4.put;
              _context3.next = 3;
              return call(_getPublicKey);

            case 3:
              res = _context3.sent;

              if (!res) {
                _context3.next = 7;
                break;
              }

              _context3.next = 7;
              return put({
                type: 'updateState',
                payload: {
                  publicKey: res.publicKey
                }
              });

            case 7:
              return _context3.abrupt("return", res);

            case 8:
            case "end":
              return _context3.stop();
          }
        }
      }, getPublicKey);
    }),
    initLovCode: /*#__PURE__*/_regeneratorRuntime.mark(function initLovCode(_ref5, _ref6) {
      var payload, call, put, lovCodes, res, response, dateMap, timeMap;
      return _regeneratorRuntime.wrap(function initLovCode$(_context4) {
        while (1) {
          switch (_context4.prev = _context4.next) {
            case 0:
              payload = _ref5.payload;
              call = _ref6.call, put = _ref6.put;
              lovCodes = payload.lovCodes;
              _context4.next = 5;
              return call(queryMapIdpValue, lovCodes);

            case 5:
              res = _context4.sent;
              response = getResponse(res);
              dateMap = {};

              if (response.dateMap) {
                _forEach(response.dateMap, function (date) {
                  dateMap[date.value] = date;
                });
              }

              timeMap = {};

              if (response.timeMap) {
                _forEach(response.timeMap, function (time) {
                  timeMap[time.value] = time;
                });
              }

              _context4.next = 13;
              return put({
                type: 'updateState',
                payload: _objectSpread(_objectSpread({}, response), {}, {
                  dateMap: dateMap,
                  timeMap: timeMap
                })
              });

            case 13:
            case "end":
              return _context4.stop();
          }
        }
      }, initLovCode);
    }),
    // 获取系统支持的菜单布局
    initMenuDataSource: /*#__PURE__*/_regeneratorRuntime.mark(function initMenuDataSource(_, _ref7) {
      var call, put, menuMap;
      return _regeneratorRuntime.wrap(function initMenuDataSource$(_context5) {
        while (1) {
          switch (_context5.prev = _context5.next) {
            case 0:
              call = _ref7.call, put = _ref7.put;
              _context5.t0 = getResponse;
              _context5.next = 4;
              return call(queryIdpValue, 'CPFM.MENU_LAYOUT');

            case 4:
              _context5.t1 = _context5.sent;
              menuMap = (0, _context5.t0)(_context5.t1);

              if (!menuMap) {
                _context5.next = 9;
                break;
              }

              _context5.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  menuMap: menuMap
                }
              });

            case 9:
            case "end":
              return _context5.stop();
          }
        }
      }, initMenuDataSource);
    }),
    // 获取系统角色合并
    initRoleMergeDataSource: /*#__PURE__*/_regeneratorRuntime.mark(function initRoleMergeDataSource(_, _ref8) {
      var call, put, roleMergeMap;
      return _regeneratorRuntime.wrap(function initRoleMergeDataSource$(_context6) {
        while (1) {
          switch (_context6.prev = _context6.next) {
            case 0:
              call = _ref8.call, put = _ref8.put;
              _context6.t0 = getResponse;
              _context6.next = 4;
              return call(queryIdpValue, 'CPFM.ENABLED_FLAG');

            case 4:
              _context6.t1 = _context6.sent;
              roleMergeMap = (0, _context6.t0)(_context6.t1);

              if (!roleMergeMap) {
                _context6.next = 9;
                break;
              }

              _context6.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  roleMergeMap: roleMergeMap
                }
              });

            case 9:
            case "end":
              return _context6.stop();
          }
        }
      }, initRoleMergeDataSource);
    }),
    // 获取系统支持的日期格式
    initDateFormat: /*#__PURE__*/_regeneratorRuntime.mark(function initDateFormat(_, _ref9) {
      var call, put, dateFormat, dateMap;
      return _regeneratorRuntime.wrap(function initDateFormat$(_context7) {
        while (1) {
          switch (_context7.prev = _context7.next) {
            case 0:
              call = _ref9.call, put = _ref9.put;
              _context7.next = 3;
              return call(queryIdpValue, 'CIAM.DATE_FORMAT');

            case 3:
              dateFormat = _context7.sent;
              dateFormat = getResponse(dateFormat);

              if (!dateFormat) {
                _context7.next = 10;
                break;
              }

              dateMap = {};

              _forEach(dateFormat, function (date) {
                dateMap[date.value] = date;
              });

              _context7.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  dateMap: dateMap
                }
              });

            case 10:
            case "end":
              return _context7.stop();
          }
        }
      }, initDateFormat);
    }),
    // 获取系统支持的时间格式
    initTimeFormat: /*#__PURE__*/_regeneratorRuntime.mark(function initTimeFormat(_, _ref10) {
      var call, put, timeFormat, timeMap;
      return _regeneratorRuntime.wrap(function initTimeFormat$(_context8) {
        while (1) {
          switch (_context8.prev = _context8.next) {
            case 0:
              call = _ref10.call, put = _ref10.put;
              _context8.next = 3;
              return call(queryIdpValue, 'CIAM.TIME_FORMAT');

            case 3:
              timeFormat = _context8.sent;
              timeFormat = getResponse(timeFormat);

              if (!timeFormat) {
                _context8.next = 10;
                break;
              }

              timeMap = {};

              _forEach(timeFormat, function (time) {
                timeMap[time.value] = time;
              });

              _context8.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  timeMap: timeMap
                }
              });

            case 10:
            case "end":
              return _context8.stop();
          }
        }
      }, initTimeFormat);
    }),
    // 获取系统首页弹窗提醒的设置
    initReminderFlagData: /*#__PURE__*/_regeneratorRuntime.mark(function initReminderFlagData(_, _ref11) {
      var call, put, reminderFlagMap;
      return _regeneratorRuntime.wrap(function initReminderFlagData$(_context9) {
        while (1) {
          switch (_context9.prev = _context9.next) {
            case 0:
              call = _ref11.call, put = _ref11.put;
              _context9.t0 = getResponse;
              _context9.next = 4;
              return call(queryIdpValue, 'CPFM.ENABLED_FLAG');

            case 4:
              _context9.t1 = _context9.sent;
              reminderFlagMap = (0, _context9.t0)(_context9.t1);

              if (!reminderFlagMap) {
                _context9.next = 9;
                break;
              }

              _context9.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  reminderFlagMap: reminderFlagMap
                }
              });

            case 9:
            case "end":
              return _context9.stop();
          }
        }
      }, initReminderFlagData);
    }),
    // 更新默认语言
    updateLanguage: /*#__PURE__*/_regeneratorRuntime.mark(function updateLanguage(_ref12, _ref13) {
      var payload, call, put, language, languageName, userInfo, result;
      return _regeneratorRuntime.wrap(function updateLanguage$(_context10) {
        while (1) {
          switch (_context10.prev = _context10.next) {
            case 0:
              payload = _ref12.payload;
              call = _ref13.call, put = _ref13.put;
              language = payload.language, languageName = payload.languageName, userInfo = payload.userInfo;
              _context10.next = 5;
              return call(updateDefaultLanguage, {
                language: language
              });

            case 5:
              result = _context10.sent;
              result = getResponse(result);

              if (!result) {
                _context10.next = 12;
                break;
              }

              _context10.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    language: language,
                    languageName: languageName
                  })
                }
              });

            case 10:
              // // 更新 global 的语言
              // yield put({
              //   type: 'global/changeLanguage',
              //   payload: language,
              // });
              // // 和 global 调用的同一个接口
              // yield put({
              //   type: 'global/updateDefaultLanguage',
              //   payload: { language },
              // });
              notification.success();
              return _context10.abrupt("return", result);

            case 12:
            case "end":
              return _context10.stop();
          }
        }
      }, updateLanguage);
    }),
    // 更新菜单布局
    updateMenuType: /*#__PURE__*/_regeneratorRuntime.mark(function updateMenuType(_ref14, _ref15) {
      var payload, call, put, _payload$menuLayout, menuLayout, userInfo, result;

      return _regeneratorRuntime.wrap(function updateMenuType$(_context11) {
        while (1) {
          switch (_context11.prev = _context11.next) {
            case 0:
              payload = _ref14.payload;
              call = _ref15.call, put = _ref15.put;
              _payload$menuLayout = payload.menuLayout, menuLayout = _payload$menuLayout === void 0 ? 'default' : _payload$menuLayout, userInfo = payload.userInfo;
              _context11.next = 5;
              return call(updateDefaultMenu, {
                menuLayout: menuLayout
              });

            case 5:
              result = _context11.sent;
              result = getResponse(result);

              if (!result) {
                _context11.next = 14;
                break;
              }

              _context11.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    menuLayout: menuLayout
                  })
                }
              });

            case 10:
              _context11.next = 12;
              return put({
                type: 'user/updateCurrentUser',
                payload: {
                  menuLayout: menuLayout
                }
              });

            case 12:
              notification.success();
              return _context11.abrupt("return", result);

            case 14:
            case "end":
              return _context11.stop();
          }
        }
      }, updateMenuType);
    }),
    // 更新角色合并
    updateRoleMerge: /*#__PURE__*/_regeneratorRuntime.mark(function updateRoleMerge(_ref16, _ref17) {
      var payload, call, put, _payload$roleMergeFla, roleMergeFlag, userInfo, result;

      return _regeneratorRuntime.wrap(function updateRoleMerge$(_context12) {
        while (1) {
          switch (_context12.prev = _context12.next) {
            case 0:
              payload = _ref16.payload;
              call = _ref17.call, put = _ref17.put;
              _payload$roleMergeFla = payload.roleMergeFlag, roleMergeFlag = _payload$roleMergeFla === void 0 ? -1 : _payload$roleMergeFla, userInfo = payload.userInfo;
              _context12.next = 5;
              return call(updateDefaultMenu, {
                roleMergeFlag: roleMergeFlag
              });

            case 5:
              result = _context12.sent;
              result = getResponse(result);

              if (!result) {
                _context12.next = 12;
                break;
              }

              _context12.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    roleMergeFlag: roleMergeFlag
                  })
                }
              });

            case 10:
              notification.success();
              return _context12.abrupt("return", result);

            case 12:
            case "end":
              return _context12.stop();
          }
        }
      }, updateRoleMerge);
    }),
    // 更新默认时间格式
    updateDateFormat: /*#__PURE__*/_regeneratorRuntime.mark(function updateDateFormat(_ref18, _ref19) {
      var payload, call, put, dateFormat, dateFormatMeaning, userInfo, result;
      return _regeneratorRuntime.wrap(function updateDateFormat$(_context13) {
        while (1) {
          switch (_context13.prev = _context13.next) {
            case 0:
              payload = _ref18.payload;
              call = _ref19.call, put = _ref19.put;
              dateFormat = payload.dateFormat, dateFormatMeaning = payload.dateFormatMeaning, userInfo = payload.userInfo;
              _context13.next = 5;
              return call(updateDefaultDate, {
                dateFormat: dateFormat,
                timeFormat: userInfo.timeFormat
              });

            case 5:
              result = _context13.sent;
              result = getResponse(result);

              if (!result) {
                _context13.next = 14;
                break;
              }

              _context13.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    dateFormat: dateFormat,
                    dateFormatMeaning: dateFormatMeaning
                  })
                }
              });

            case 10:
              _context13.next = 12;
              return put({
                type: 'user/updateCurrentUser',
                payload: {
                  dateFormat: dateFormat,
                  dateTimeFormat: "".concat(dateFormat, " ").concat(userInfo.timeFormat)
                }
              });

            case 12:
              notification.success();
              return _context13.abrupt("return", result);

            case 14:
            case "end":
              return _context13.stop();
          }
        }
      }, updateDateFormat);
    }),
    // 更新默认日期格式
    updateTimeFormat: /*#__PURE__*/_regeneratorRuntime.mark(function updateTimeFormat(_ref20, _ref21) {
      var payload, call, put, timeFormat, timeFormatMeaning, userInfo, result;
      return _regeneratorRuntime.wrap(function updateTimeFormat$(_context14) {
        while (1) {
          switch (_context14.prev = _context14.next) {
            case 0:
              payload = _ref20.payload;
              call = _ref21.call, put = _ref21.put;
              timeFormat = payload.timeFormat, timeFormatMeaning = payload.timeFormatMeaning, userInfo = payload.userInfo;
              _context14.next = 5;
              return call(updateDefaultDate, {
                timeFormat: timeFormat,
                dateFormat: userInfo.dateFormat
              });

            case 5:
              result = _context14.sent;
              result = getResponse(result);

              if (!result) {
                _context14.next = 14;
                break;
              }

              _context14.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    timeFormat: timeFormat,
                    timeFormatMeaning: timeFormatMeaning
                  })
                }
              });

            case 10:
              _context14.next = 12;
              return put({
                type: 'user/updateCurrentUser',
                payload: {
                  timeFormat: timeFormat,
                  dataTimeFormat: "".concat(userInfo.dateFormat, " ").concat(timeFormat)
                }
              });

            case 12:
              notification.success();
              return _context14.abrupt("return", result);

            case 14:
            case "end":
              return _context14.stop();
          }
        }
      }, updateTimeFormat);
    }),
    // 更新默认时区
    updateTimeZone: /*#__PURE__*/_regeneratorRuntime.mark(function updateTimeZone(_ref22, _ref23) {
      var payload, call, put, timeZone, timeZoneMeaning, userInfo, result;
      return _regeneratorRuntime.wrap(function updateTimeZone$(_context15) {
        while (1) {
          switch (_context15.prev = _context15.next) {
            case 0:
              payload = _ref22.payload;
              call = _ref23.call, put = _ref23.put;
              timeZone = payload.timeZone, timeZoneMeaning = payload.timeZoneMeaning, userInfo = payload.userInfo;
              _context15.next = 5;
              return call(updateDefaultTimeZone, {
                timeZone: timeZone
              });

            case 5:
              result = _context15.sent;
              result = getResponse(result);

              if (!result) {
                _context15.next = 14;
                break;
              }

              _context15.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    timeZone: timeZone,
                    timeZoneMeaning: timeZoneMeaning
                  })
                }
              });

            case 10:
              _context15.next = 12;
              return put({
                type: 'user/updateCurrentUser',
                payload: {
                  timeZone: timeZone
                }
              });

            case 12:
              notification.success();
              return _context15.abrupt("return", result);

            case 14:
            case "end":
              return _context15.stop();
          }
        }
      }, updateTimeZone);
    }),
    // 更新昵称
    updateRealName: /*#__PURE__*/_regeneratorRuntime.mark(function updateRealName(_ref24, _ref25) {
      var payload, call, put, realName, userInfo, res;
      return _regeneratorRuntime.wrap(function updateRealName$(_context16) {
        while (1) {
          switch (_context16.prev = _context16.next) {
            case 0:
              payload = _ref24.payload;
              call = _ref25.call, put = _ref25.put;
              realName = payload.realName, userInfo = payload.userInfo;
              _context16.t0 = getResponse;
              _context16.next = 6;
              return call(userInfoUpdateRealName, realName);

            case 6:
              _context16.t1 = _context16.sent;
              res = (0, _context16.t0)(_context16.t1);

              if (!res) {
                _context16.next = 12;
                break;
              }

              notification.success();
              _context16.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    realName: realName
                  })
                }
              });

            case 12:
              return _context16.abrupt("return", res);

            case 13:
            case "end":
              return _context16.stop();
          }
        }
      }, updateRealName);
    }),
    // 更新默认角色
    updateRole: /*#__PURE__*/_regeneratorRuntime.mark(function updateRole(_ref26, _ref27) {
      var payload, call, put, defaultRoleId, defaultRoleName, organizationId, userInfo, res;
      return _regeneratorRuntime.wrap(function updateRole$(_context17) {
        while (1) {
          switch (_context17.prev = _context17.next) {
            case 0:
              payload = _ref26.payload;
              call = _ref27.call, put = _ref27.put;
              defaultRoleId = payload.defaultRoleId, defaultRoleName = payload.defaultRoleName, organizationId = payload.organizationId, userInfo = payload.userInfo;
              _context17.t0 = getResponse;
              _context17.next = 6;
              return call(userInfoUpdateDefaultRole, organizationId, defaultRoleId);

            case 6:
              _context17.t1 = _context17.sent;
              res = (0, _context17.t0)(_context17.t1);

              if (!res) {
                _context17.next = 12;
                break;
              }

              notification.success();
              _context17.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  roleProps: {},
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    defaultRoleId: defaultRoleId,
                    defaultRoleName: defaultRoleName
                  })
                }
              });

            case 12:
              return _context17.abrupt("return", res);

            case 13:
            case "end":
              return _context17.stop();
          }
        }
      }, updateRole);
    }),
    // 更新默认公司
    updateCompany: /*#__PURE__*/_regeneratorRuntime.mark(function updateCompany(_ref28, _ref29) {
      var payload, call, put, defaultCompanyId, defaultCompanyName, userInfo, organizationId, res;
      return _regeneratorRuntime.wrap(function updateCompany$(_context18) {
        while (1) {
          switch (_context18.prev = _context18.next) {
            case 0:
              payload = _ref28.payload;
              call = _ref29.call, put = _ref29.put;
              defaultCompanyId = payload.defaultCompanyId, defaultCompanyName = payload.defaultCompanyName, userInfo = payload.userInfo, organizationId = payload.organizationId;
              _context18.t0 = getResponse;
              _context18.next = 6;
              return call(userInfoUpdateDefaultCompany, organizationId, defaultCompanyId);

            case 6:
              _context18.t1 = _context18.sent;
              res = (0, _context18.t0)(_context18.t1);

              if (!res) {
                _context18.next = 12;
                break;
              }

              notification.success();
              _context18.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  companyProps: {},
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    defaultCompanyId: defaultCompanyId,
                    defaultCompanyName: defaultCompanyName
                  })
                }
              });

            case 12:
              return _context18.abrupt("return", res);

            case 13:
            case "end":
              return _context18.stop();
          }
        }
      }, updateCompany);
    }),
    // 更新首页消息弹窗提醒状态
    updateReminderFlag: /*#__PURE__*/_regeneratorRuntime.mark(function updateReminderFlag(_ref30, _ref31) {
      var payload, call, put, _payload$popoutRemind, popoutReminderFlag, userInfo, result;

      return _regeneratorRuntime.wrap(function updateReminderFlag$(_context19) {
        while (1) {
          switch (_context19.prev = _context19.next) {
            case 0:
              payload = _ref30.payload;
              call = _ref31.call, put = _ref31.put;
              _payload$popoutRemind = payload.popoutReminderFlag, popoutReminderFlag = _payload$popoutRemind === void 0 ? -1 : _payload$popoutRemind, userInfo = payload.userInfo;
              _context19.next = 5;
              return call(updateDefaultMenu, {
                popoutReminderFlag: popoutReminderFlag
              });

            case 5:
              result = _context19.sent;
              result = getResponse(result);

              if (!result) {
                _context19.next = 12;
                break;
              }

              _context19.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    reminderFlag: popoutReminderFlag
                  })
                }
              });

            case 10:
              notification.success();
              return _context19.abrupt("return", result);

            case 12:
            case "end":
              return _context19.stop();
          }
        }
      }, updateReminderFlag);
    }),
    // 关闭模态框
    closeForm: /*#__PURE__*/_regeneratorRuntime.mark(function closeForm(_ref32, _ref33) {
      var payload, put, modalProps, title, formItems, _modalProps$validCach, validCache;

      return _regeneratorRuntime.wrap(function closeForm$(_context20) {
        while (1) {
          switch (_context20.prev = _context20.next) {
            case 0:
              payload = _ref32.payload;
              put = _ref33.put;
              modalProps = payload.modalProps; // 保留 modal 的,title,formItems, 保证在动画的时候不会与编辑时不一样.

              title = modalProps.title, formItems = modalProps.formItems, _modalProps$validCach = modalProps.validCache, validCache = _modalProps$validCach === void 0 ? {} : _modalProps$validCach;
              _context20.next = 6;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: {
                    validCache: validCache,
                    title: title,
                    formItems: formItems,
                    visible: false
                  }
                }
              });

            case 6:
            case "end":
              return _context20.stop();
          }
        }
      }, closeForm);
    }),
    // 打开模态框
    openForm: /*#__PURE__*/_regeneratorRuntime.mark(function openForm(_ref34, _ref35) {
      var payload, put, modalProps, params, title, formItems, lastCheckKey, captchaKey, _modalProps$validCach2, validCache, step;

      return _regeneratorRuntime.wrap(function openForm$(_context21) {
        while (1) {
          switch (_context21.prev = _context21.next) {
            case 0:
              payload = _ref34.payload;
              put = _ref35.put;
              modalProps = payload.modalProps, params = _objectWithoutProperties(payload, _excluded);
              title = modalProps.title, formItems = modalProps.formItems, lastCheckKey = modalProps.lastCheckKey, captchaKey = modalProps.captchaKey, _modalProps$validCach2 = modalProps.validCache, validCache = _modalProps$validCach2 === void 0 ? {} : _modalProps$validCach2;
              step = payload.step;
              _context21.next = 7;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: _objectSpread(_objectSpread(_objectSpread({
                    title: title,
                    formItems: formItems,
                    lastCheckKey: lastCheckKey,
                    captchaKey: captchaKey,
                    validCache: validCache,
                    step: step
                  }, validCache[step]), params), {}, {
                    visible: true
                  })
                }
              });

            case 7:
            case "end":
              return _context21.stop();
          }
        }
      }, openForm);
    }),
    // 停止 倒计时
    captchaLimitEnd: /*#__PURE__*/_regeneratorRuntime.mark(function captchaLimitEnd(_ref36, _ref37) {
      var payload, put, modalProps;
      return _regeneratorRuntime.wrap(function captchaLimitEnd$(_context22) {
        while (1) {
          switch (_context22.prev = _context22.next) {
            case 0:
              payload = _ref36.payload;
              put = _ref37.put;
              modalProps = payload.modalProps;
              _context22.next = 5;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: _objectSpread(_objectSpread({}, modalProps), {}, {
                    validCodeSendLimitFlag: false
                  })
                }
              });

            case 5:
            case "end":
              return _context22.stop();
          }
        }
      }, captchaLimitEnd);
    }),
    // 发送验证码
    postCaptcha: /*#__PURE__*/_regeneratorRuntime.mark(function postCaptcha(_ref38, _ref39) {
      var payload, call, put, type, value, modalProps, params, queryParams, service, field, captchaField, needCacheValidTime, res, validCodeLimitTimeStart, validCodeLimitTimeEnd, nextModalProps;
      return _regeneratorRuntime.wrap(function postCaptcha$(_context23) {
        while (1) {
          switch (_context23.prev = _context23.next) {
            case 0:
              payload = _ref38.payload;
              call = _ref39.call, put = _ref39.put;
              type = payload.type, value = payload.value, modalProps = payload.modalProps, params = _objectWithoutProperties(payload, _excluded2);
              queryParams = _objectSpread({}, params);
              captchaField = 'captchaKey';
              needCacheValidTime = false; // 不只需要存储时间 还需要存储对应的 key

              _context23.t0 = type;
              _context23.next = _context23.t0 === 'newPhone' ? 9 : _context23.t0 === 'newEmail' ? 12 : _context23.t0 === 'oldEmail' ? 15 : _context23.t0 === 'oldPhone' ? 19 : 19;
              break;

            case 9:
              service = userInfoPostNewPhoneCaptcha;
              field = 'phone';
              return _context23.abrupt("break", 23);

            case 12:
              service = userInfoPostNewEmailCaptcha;
              field = 'email';
              return _context23.abrupt("break", 23);

            case 15:
              needCacheValidTime = true;
              service = userInfoPostOldEmailCaptcha;
              field = 'email';
              return _context23.abrupt("break", 23);

            case 19:
              needCacheValidTime = true;
              service = userInfoPostOldPhoneCaptcha;
              field = 'phone';
              return _context23.abrupt("break", 23);

            case 23:
              if (field) {
                queryParams[field] = value;
              }

              _context23.t1 = getResponse;
              _context23.next = 27;
              return call(service, queryParams);

            case 27:
              _context23.t2 = _context23.sent;
              res = (0, _context23.t1)(_context23.t2);
              validCodeLimitTimeStart = new Date().getTime(); // 60秒限制

              validCodeLimitTimeEnd = validCodeLimitTimeStart + 60000;
              nextModalProps = _objectSpread({}, modalProps);

              if (res) {
                notification.success({
                  message: res.message
                });

                if (captchaField) {
                  nextModalProps[captchaField] = res[captchaField]; // 存储对应的 验证码的 captchaKey

                  if (needCacheValidTime) {
                    setSession("user-info-".concat(type), res[captchaField] || 0);
                  }

                  nextModalProps.validCodeSendLimitFlag = true;
                  nextModalProps.validCodeLimitTimeEnd = validCodeLimitTimeEnd;

                  if (needCacheValidTime) {
                    nextModalProps.validCache = _objectSpread(_objectSpread({}, modalProps.validCache), {}, _defineProperty({}, modalProps.step, {
                      validCodeSendLimitFlag: true,
                      validCodeLimitTimeEnd: validCodeLimitTimeEnd
                    }));
                  }
                }
              }

              _context23.next = 35;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: nextModalProps
                }
              });

            case 35:
              return _context23.abrupt("return", res);

            case 36:
            case "end":
              return _context23.stop();
          }
        }
      }, postCaptcha);
    }),
    validatePrePassword: /*#__PURE__*/_regeneratorRuntime.mark(function validatePrePassword(_ref40, _ref41) {
      var payload, call, put, modalProps, params, res, nextModalProps;
      return _regeneratorRuntime.wrap(function validatePrePassword$(_context24) {
        while (1) {
          switch (_context24.prev = _context24.next) {
            case 0:
              payload = _ref40.payload;
              call = _ref41.call, put = _ref41.put;
              modalProps = payload.modalProps, params = _objectWithoutProperties(payload, _excluded3);
              _context24.t0 = getResponse;
              _context24.next = 6;
              return call(userInfoValidatePrePassword, params);

            case 6:
              _context24.t1 = _context24.sent;
              res = (0, _context24.t0)(_context24.t1);
              nextModalProps = _objectSpread({}, modalProps);

              if (res) {
                notification.success();
                nextModalProps.lastCheckKey = res.lastCheckKey;
              }

              _context24.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: nextModalProps
                }
              });

            case 12:
              return _context24.abrupt("return", res);

            case 13:
            case "end":
              return _context24.stop();
          }
        }
      }, validatePrePassword);
    }),
    validatePreValidate: /*#__PURE__*/_regeneratorRuntime.mark(function validatePreValidate(_ref42, _ref43) {
      var payload, call, put, captchaKey, type, captcha, modalProps, res, nextModalProps, sessionCaptchaKey;
      return _regeneratorRuntime.wrap(function validatePreValidate$(_context25) {
        while (1) {
          switch (_context25.prev = _context25.next) {
            case 0:
              payload = _ref42.payload;
              call = _ref43.call, put = _ref43.put;
              captchaKey = payload.captchaKey, type = payload.type, captcha = payload.captcha, modalProps = payload.modalProps;
              nextModalProps = _objectSpread({}, modalProps);

              if (!captchaKey) {
                _context25.next = 13;
                break;
              }

              _context25.t0 = getResponse;
              _context25.next = 8;
              return call(userInfoValidatePre, {
                captchaKey: captchaKey,
                captcha: captcha,
                businessScope: 'self'
              });

            case 8:
              _context25.t1 = _context25.sent;
              res = (0, _context25.t0)(_context25.t1);
              // 清除 nextModalProps 里面的 captchaKey
              nextModalProps.captchaKey = undefined;
              _context25.next = 21;
              break;

            case 13:
              sessionCaptchaKey = getSession("user-info-".concat(type)); // 清除 sessionStorage 里面的 captchaKey

              setSession("user-info-".concat(type), 0);

              if (!sessionCaptchaKey) {
                _context25.next = 21;
                break;
              }

              _context25.t2 = getResponse;
              _context25.next = 19;
              return call(userInfoValidatePre, {
                captchaKey: sessionCaptchaKey,
                captcha: captcha,
                businessScope: 'self'
              });

            case 19:
              _context25.t3 = _context25.sent;
              res = (0, _context25.t2)(_context25.t3);

            case 21:
              if (res) {
                notification.success();
                nextModalProps.lastCheckKey = res.lastCheckKey;
              }

              _context25.next = 24;
              return put({
                type: 'updateState',
                payload: {
                  modalProps: nextModalProps
                }
              });

            case 24:
              return _context25.abrupt("return", res);

            case 25:
            case "end":
              return _context25.stop();
          }
        }
      }, validatePreValidate);
    }),
    // 验证并更新邮箱
    validateNewEmail: /*#__PURE__*/_regeneratorRuntime.mark(function validateNewEmail(_ref44, _ref45) {
      var payload, call, put, userInfo, params, res;
      return _regeneratorRuntime.wrap(function validateNewEmail$(_context26) {
        while (1) {
          switch (_context26.prev = _context26.next) {
            case 0:
              payload = _ref44.payload;
              call = _ref45.call, put = _ref45.put;
              userInfo = payload.userInfo, params = _objectWithoutProperties(payload, _excluded4);
              _context26.t0 = getResponse;
              _context26.next = 6;
              return call(userInfoValidateNewEmail, params);

            case 6:
              _context26.t1 = _context26.sent;
              res = (0, _context26.t0)(_context26.t1);

              if (!res) {
                _context26.next = 12;
                break;
              }

              notification.success({
                message: res.message
              });
              _context26.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    email: payload.email,
                    emailCheckFlag: 1 // 绑定邮箱后 更新 emailCheckFlag

                  })
                }
              });

            case 12:
              return _context26.abrupt("return", res);

            case 13:
            case "end":
              return _context26.stop();
          }
        }
      }, validateNewEmail);
    }),
    // 验证并更新手机
    validateNewPhone: /*#__PURE__*/_regeneratorRuntime.mark(function validateNewPhone(_ref46, _ref47) {
      var payload, call, put, userInfo, params, res;
      return _regeneratorRuntime.wrap(function validateNewPhone$(_context27) {
        while (1) {
          switch (_context27.prev = _context27.next) {
            case 0:
              payload = _ref46.payload;
              call = _ref47.call, put = _ref47.put;
              userInfo = payload.userInfo, params = _objectWithoutProperties(payload, _excluded5);
              _context27.t0 = getResponse;
              _context27.next = 6;
              return call(userInfoValidateNewPhone, params);

            case 6:
              _context27.t1 = _context27.sent;
              res = (0, _context27.t0)(_context27.t1);

              if (!res) {
                _context27.next = 12;
                break;
              }

              notification.success({
                message: res.message
              });
              _context27.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    phone: params.phone
                  })
                }
              });

            case 12:
              return _context27.abrupt("return", res);

            case 13:
            case "end":
              return _context27.stop();
          }
        }
      }, validateNewPhone);
    }),
    // 更新密码
    updatePassword: /*#__PURE__*/_regeneratorRuntime.mark(function updatePassword(_ref48, _ref49) {
      var payload, call, put, password, originalPassword, _payload$userInfo, userInfo, res;

      return _regeneratorRuntime.wrap(function updatePassword$(_context28) {
        while (1) {
          switch (_context28.prev = _context28.next) {
            case 0:
              payload = _ref48.payload;
              call = _ref49.call, put = _ref49.put;
              password = payload.password, originalPassword = payload.originalPassword, _payload$userInfo = payload.userInfo, userInfo = _payload$userInfo === void 0 ? {} : _payload$userInfo;
              _context28.next = 5;
              return call(userInfoUpdatePassword, {
                password: password,
                originalPassword: originalPassword
              });

            case 5:
              res = _context28.sent;

              if (!(res && !res.failed)) {
                _context28.next = 10;
                break;
              }

              _context28.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    passwordResetFlag: 1
                  })
                }
              });

            case 9:
              notification.success({
                message: res.message
              }); // 需要刷新界面,因为密码安全等级 是由后端 计算的。

            case 10:
              return _context28.abrupt("return", res);

            case 11:
            case "end":
              return _context28.stop();
          }
        }
      }, updatePassword);
    }),
    // 获取密码校验规则
    getPasswordRule: /*#__PURE__*/_regeneratorRuntime.mark(function getPasswordRule(_ref50, _ref51) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function getPasswordRule$(_context29) {
        while (1) {
          switch (_context29.prev = _context29.next) {
            case 0:
              payload = _ref50.payload;
              call = _ref51.call, put = _ref51.put;
              _context29.t0 = getResponse;
              _context29.next = 5;
              return call(_getPasswordRule, payload);

            case 5:
              _context29.t1 = _context29.sent;
              res = (0, _context29.t0)(_context29.t1);

              if (!res) {
                _context29.next = 10;
                break;
              }

              _context29.next = 10;
              return put({
                type: 'updateState',
                payload: {
                  passwordTipMsg: res
                }
              });

            case 10:
              return _context29.abrupt("return", res);

            case 11:
            case "end":
              return _context29.stop();
          }
        }
      }, getPasswordRule);
    }),
    // 验证并绑定手机号
    validateUnCheckedPhone: /*#__PURE__*/_regeneratorRuntime.mark(function validateUnCheckedPhone(_ref52, _ref53) {
      var payload, call, put, captchaKey, captcha, userInfo, businessScope, res;
      return _regeneratorRuntime.wrap(function validateUnCheckedPhone$(_context30) {
        while (1) {
          switch (_context30.prev = _context30.next) {
            case 0:
              payload = _ref52.payload;
              call = _ref53.call, put = _ref53.put;
              captchaKey = payload.captchaKey, captcha = payload.captcha, userInfo = payload.userInfo, businessScope = payload.businessScope;
              _context30.t0 = getResponse;
              _context30.next = 6;
              return call(userInfoValidateUnCheckedPhone, {
                captchaKey: captchaKey,
                captcha: captcha,
                businessScope: businessScope
              });

            case 6:
              _context30.t1 = _context30.sent;
              res = (0, _context30.t0)(_context30.t1);

              if (!res) {
                _context30.next = 12;
                break;
              }

              notification.success({
                message: res.message
              });
              _context30.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    phoneCheckFlag: 1
                  })
                }
              });

            case 12:
              return _context30.abrupt("return", res);

            case 13:
            case "end":
              return _context30.stop();
          }
        }
      }, validateUnCheckedPhone);
    }),
    // 验证并绑定邮箱
    validateUnCheckedEmail: /*#__PURE__*/_regeneratorRuntime.mark(function validateUnCheckedEmail(_ref54, _ref55) {
      var payload, call, put, captchaKey, captcha, userInfo, businessScope, res;
      return _regeneratorRuntime.wrap(function validateUnCheckedEmail$(_context31) {
        while (1) {
          switch (_context31.prev = _context31.next) {
            case 0:
              payload = _ref54.payload;
              call = _ref55.call, put = _ref55.put;
              captchaKey = payload.captchaKey, captcha = payload.captcha, userInfo = payload.userInfo, businessScope = payload.businessScope;
              _context31.t0 = getResponse;
              _context31.next = 6;
              return call(userInfoValidateUnCheckedEmail, {
                captchaKey: captchaKey,
                captcha: captcha,
                businessScope: businessScope
              });

            case 6:
              _context31.t1 = _context31.sent;
              res = (0, _context31.t0)(_context31.t1);

              if (!res) {
                _context31.next = 12;
                break;
              }

              notification.success({
                message: res.message
              });
              _context31.next = 12;
              return put({
                type: 'updateState',
                payload: {
                  userInfo: _objectSpread(_objectSpread({}, userInfo), {}, {
                    emailCheckFlag: 1
                  })
                }
              });

            case 12:
              return _context31.abrupt("return", res);

            case 13:
            case "end":
              return _context31.stop();
          }
        }
      }, validateUnCheckedEmail);
    }),
    // 获取头像可上传的文件类型和大小
    fetchEnabledFile: /*#__PURE__*/_regeneratorRuntime.mark(function fetchEnabledFile(_ref56, _ref57) {
      var payload, call, put, res, result;
      return _regeneratorRuntime.wrap(function fetchEnabledFile$(_context32) {
        while (1) {
          switch (_context32.prev = _context32.next) {
            case 0:
              payload = _ref56.payload;
              call = _ref57.call, put = _ref57.put;
              _context32.next = 4;
              return call(_fetchEnabledFile, payload);

            case 4:
              res = _context32.sent;
              result = getResponse(res);

              if (!result) {
                _context32.next = 9;
                break;
              }

              _context32.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  limitData: result
                }
              });

            case 9:
              return _context32.abrupt("return", result);

            case 10:
            case "end":
              return _context32.stop();
          }
        }
      }, fetchEnabledFile);
    }),
    // 上传裁剪好的图片
    uploadAvatar: /*#__PURE__*/_regeneratorRuntime.mark(function uploadAvatar(_ref58, _ref59) {
      var payload, call, put, res, result;
      return _regeneratorRuntime.wrap(function uploadAvatar$(_context33) {
        while (1) {
          switch (_context33.prev = _context33.next) {
            case 0:
              payload = _ref58.payload;
              call = _ref59.call, put = _ref59.put;
              _context33.next = 4;
              return call(_uploadAvatar, payload);

            case 4:
              res = _context33.sent;
              result = getResponse(res);

              if (!result) {
                _context33.next = 11;
                break;
              }

              _context33.next = 9;
              return put({
                type: 'updateState',
                payload: {
                  imgUploadStatus: 'done'
                }
              });

            case 9:
              _context33.next = 13;
              break;

            case 11:
              _context33.next = 13;
              return put({
                type: 'updateState',
                payload: {
                  imgUploadStatus: 'faild'
                }
              });

            case 13:
              return _context33.abrupt("return", result);

            case 14:
            case "end":
              return _context33.stop();
          }
        }
      }, uploadAvatar);
    }),
    // 保存头像
    saveAvatar: /*#__PURE__*/_regeneratorRuntime.mark(function saveAvatar(_ref60, _ref61) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function saveAvatar$(_context34) {
        while (1) {
          switch (_context34.prev = _context34.next) {
            case 0:
              payload = _ref60.payload;
              call = _ref61.call;
              _context34.next = 4;
              return call(_saveAvatar, payload);

            case 4:
              res = _context34.sent;
              return _context34.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context34.stop();
          }
        }
      }, saveAvatar);
    }),
    fetchOpenAccountList: /*#__PURE__*/_regeneratorRuntime.mark(function fetchOpenAccountList(_ref62, _ref63) {
      var payload, call, put, res;
      return _regeneratorRuntime.wrap(function fetchOpenAccountList$(_context35) {
        while (1) {
          switch (_context35.prev = _context35.next) {
            case 0:
              payload = _ref62.payload;
              call = _ref63.call, put = _ref63.put;
              _context35.next = 4;
              return getResponse(call(_fetchOpenAccountList, payload));

            case 4:
              res = _context35.sent;

              if (!res) {
                _context35.next = 8;
                break;
              }

              _context35.next = 8;
              return put({
                type: 'updateState',
                payload: {
                  openAccountList: res
                }
              });

            case 8:
              return _context35.abrupt("return", res);

            case 9:
            case "end":
              return _context35.stop();
          }
        }
      }, fetchOpenAccountList);
    }),
    // 解除第三方绑定
    unBindOpenAccount: /*#__PURE__*/_regeneratorRuntime.mark(function unBindOpenAccount(_ref64, _ref65) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function unBindOpenAccount$(_context36) {
        while (1) {
          switch (_context36.prev = _context36.next) {
            case 0:
              payload = _ref64.payload;
              call = _ref65.call;
              _context36.next = 4;
              return call(_unBindOpenAccount, payload);

            case 4:
              res = _context36.sent;
              return _context36.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context36.stop();
          }
        }
      }, unBindOpenAccount);
    }),
    // 绑定第三方应用之前
    beforeBind: /*#__PURE__*/_regeneratorRuntime.mark(function beforeBind(_ref66, _ref67) {
      var payload, call, res;
      return _regeneratorRuntime.wrap(function beforeBind$(_context37) {
        while (1) {
          switch (_context37.prev = _context37.next) {
            case 0:
              payload = _ref66.payload;
              call = _ref67.call;
              _context37.next = 4;
              return call(_beforeBind, payload);

            case 4:
              res = _context37.sent;
              return _context37.abrupt("return", getResponse(res));

            case 6:
            case "end":
              return _context37.stop();
          }
        }
      }, beforeBind);
    })
  },
  reducers: {
    // 生成新的state
    updateState: function updateState(state, _ref68) {
      var payload = _ref68.payload;
      return _objectSpread(_objectSpread({}, state), payload);
    }
  }
};